package com.kgc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kgc.dao.UserMapper;
import com.kgc.entity.User;
import com.kgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl  implements UserService {

    @Autowired
    private UserMapper userMapper;
    public List<User> findAll() {
        return userMapper.findAll();
    }

    public void save(User user) {
        userMapper.save(user);
    }


    public void update(User user) {
            userMapper.update(user);
    }

    public User findById(int id) {
        return userMapper.findById(id);
    }

    public PageInfo<User> findByPage(int page,int pageSize,User user) {
        PageHelper.startPage(page,pageSize);
        List<User> list=userMapper.findByPage(user);
        PageInfo<User> pageInfo=new PageInfo<User>(list);
        return pageInfo;
    }

    public void delete(int id) {
        userMapper.delete(id);
    }

    public void deleteByIds(int[] ids) {
        userMapper.deleteByIds(ids);
    }
}
